/*
 * @Author: your name
 * @Date: 2020-04-16 09:49:06
 * @LastEditTime: 2020-05-08 14:34:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \v1.0.0\pages\work\interface.js
 */
import { http,navigate } from '@/common/framework'

import config from '@/common/config';

export function test () {
	return http.get('/kmlc/sys/dict/getDictItems/production_type_code',{})
}


export function getMenueList (params) {
	return http.get(config.webApiUrl+'/kmlc/sys/permission/getAppUserPermissionByToken',params)
}

export function getProductList (params) {
	return http.post(config.webApiUrl+'/kmlc/material/materialType/queryMaterialTypeAndStandTree',params)
}
//保持采购清单
export function saveProductList (params) {
	return http.post(config.webApiUrl+'/kmlc/material/billPurchase/add',params)
}

//待我审批
export function getApprovalListToMe (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/task/todo',params)
}

//我发起的审批
export function getApprovalListFromMe (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/process/historic',params)
}

//我已经审批的
export function getApprovalListFinshMe (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/task/historic',params)
}

//全部审批的
export function getApprovalList (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/task/historic',params)
}

//采购清单
export function getBuyListInfoById (params) {
	return http.get(config.webApiUrl+'/kmlc/material/billPurchase/queryById',params)
}

//采购物资
export function getBuyProductList (params) {
	return http.get(config.webApiUrl+'/kmlc/material/billPurchase/queryBillPurchaseMaterialByMainId',params)
}


//采购申请流程步骤信息
export function gethistoryFlow (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/task/historyFlow',params)
}


//采购申请提交审批意见
export function submitTask (params) {
	return http.post(config.webApiUrl+'/kmlc/material/billPurchase/submitTask',params)
}

//获取下一步审批详情
export function getTaskInfo (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/task/getTodoByProceList',params)
}


//获取下一步审批详情
export function getTaskDetail (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/task/taskDetail',params)
}

//获取下一步审批详情
export function getTaskId (params) {
	return http.get(config.webApiUrl+'/kmlc/workflow/task/queryTaskId',params)
}



//跳转到审批详情
export function goDetailPage(msgId,type) {
	// 采购流程：purchaseEnter
	// 领用流程：approval
	// 出库流程：output
	// 入库流程：enter
	let url='/pages/work/building/building';
	let [procInsId,businessKey] = msgId &&msgId.indexOf(',')>-1&&msgId.split(',');
	if(type){
		switch(type){
			case 'purchaseEnter':
				url = `/pages/work/approval_detail/approval_detail?procInsId=${procInsId}&businessKey=${businessKey}`;
			break;
			case 'approval':
				url = `/pages/work/approval_receive_detail/approval_receive_detail?procInsId=${procInsId}&businessKey=${businessKey}`;
			break;
			case 'output':
				// url = `/pages/work/approval_detail/approval_detail?procInsId=${procInsId}&businessKey=${businessKey}`;
			break;
			case 'enter':
				// url = `/pages/work/approval_detail/approval_detail?procInsId=${procInsId}&businessKey=${businessKey}`;
			break;
			default:break;
		}
	}
	
	url &&navigate.gotoPage(url);
  }

  /*-------------------领用申请----------------------------*/
  //提交领用申请
export function addBillApproval (params) {
	return http.post(config.webApiUrl+'/kmlc/material/billApproval/add',params)
}

 //获取领用申请表单信息
 export function getReceiveApplyInfo (params) {
	return http.get(config.webApiUrl+'/kmlc/material/billApproval/queryById',params)
}

 //获取领用申请产品列表
 export function getReceiveProductList (params) {
	return http.get(config.webApiUrl+'/kmlc/material/billApproval/queryBillApprovalMaterialVoByMainId',params)
}

 //获取领用申请产品列表
 export function subReceiveTask (params) {
	return http.post(config.webApiUrl+'/kmlc/material/billApproval/submitTask',params)
}
